
  let layer = layui.layer;
  getUserInfo();

  $("#quit").click(function () {
    layer.confirm("确认退出吗?", { icon: 3, title: "提示" }, function (index) {
      //do something
      localStorage.removeItem("token");
      location.href = "login.html";
      layer.close(index);
    });
  });

  function getUserInfo() {
    $.ajax({
      method: "GET",
      url: "/my/userinfo",
      success: function (res) {
        if (res.status != 0) {
          return layer.msg(res.message);
        }
        rederAvater(res.data);
      }
    });
  }
  function rederAvater(data) {
    var name = data.nickname || data.username;
    $("#welcome").html("欢迎&nbsp;&nbsp;" + name);
    if (data.user_pic != null) {
      $(".layui-nav-img").attr("src", data.user_pic).show();
      $(".text-avatar").hide();
    } else {
      $(".layui-nav-img").hide();
      $(".text-avatar").html(name[0].toUpperCase()).show();
    }
  }


